<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<link href="${pageContext.request.contextPath}/css/sys.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript">
        function changePost(obj){
            var depId=obj.value;
            var xmlhttp;
            if (window.XMLHttpRequest){
                xmlhttp=new XMLHttpRequest();
            }else{
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }

            xmlhttp.onreadystatechange=function () {
                 if(xmlhttp.readyState==4&&xmlhttp.status==200){
                     var datas=xmlhttp.responseText;
                     var jsonArray=eval("("+datas+")");
                     var mosts=document.getElementById("postSelectId");
                     mosts.innerHTML="";
                     for(var i=0;i<jsonArray.length;i++){
                         var zhiwu=jsonArray[i];
                         var postId=zhiwu.postid;
                         var postName=zhiwu.postname;
                         mosts.innerHTML+="<option value='"+postId+"'>"+postName+"</option>";
                     }
                 }
            };

            var url="${pageContext.request.contextPath}/post/listPost?depId="+depId;
            xmlhttp.open("GET",url);
            xmlhttp.send(null);
        }
    </script>
</head>

<body >
 <table border="0" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td class="topg"></td>
  </tr>
</table>

<table border="0" cellspacing="0" cellpadding="0"  class="wukuang"width="100%">
  <tr>
    <td width="1%"><img src="${pageContext.request.contextPath}/images/tleft.gif"/></td>
    <td width="39%" align="left">[员工管理]</td>
   
    <td width="57%"align="right">
    	<%--高级查询 --%>
		<a href="javascript:void(0)" onclick="document.forms[0].submit()"><img src="${pageContext.request.contextPath}/images/button/gaojichaxun.gif" /></a>
    	<%--员工注入 --%>
	  	<a href="${pageContext.request.contextPath}/staff/addStaffPage">
	  		<img src="${pageContext.request.contextPath}/images/button/tianjia.gif" />
	  	</a>
      
    </td>
    <td width="3%" align="right"><img src="${pageContext.request.contextPath}/images/tright.gif"/></td>
  </tr>
</table>

<!-- 查询条件：马上查询 -->
<form id="conditionFormId" action="${pageContext.request.contextPath}/staff/listStaffs" method="post">
	<table width="88%" border="0" style="margin: 20px;" >
	  <tr>
	    <td width="80px">部门：</td>
	    <td width="200px">
	    	
	    	<select name="crmPost.crmDepartment.depid" onchange="changePost(this)">
			    <c:forEach items="${departments}" var="department">
			        <option value="${department.depid}">${department.depname}</option>
                </c:forEach>
			</select>

	    </td>
	    <td width="80px" >职务：</td>
	    <td width="200px" >
	    	<select name="crmPost.postid" id="postSelectId">

			</select>
	    </td>
	    <td width="80px">姓名：</td>
	    <td width="200px" ><input type="text" name="staffname" size="12" value="${name}"/></td>
	    <td ></td>
	  </tr>
	</table>
</form>


<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
  <tr>
    <td ><img src="${pageContext.request.contextPath}/images/result.gif"/></td>
  </tr>
</table>

<table width="100%" border="1" >
  <tr class="henglan" style="font-weight:bold;">
    <td width="10%" align="center">员工姓名</td>
    <td width="6%" align="center">性别</td>
    <td width="12%" align="center">入职时间</td>
    <td width="15%" align="center">所属部门</td>
    <td width="10%" align="center">职务</td>
    <td width="10%" align="center">编辑</td>
  </tr>
  
    

    <c:forEach items="${pageUtil.datas}" var="staff">
	  <tr class="tabtd2"> 
	    <td align="center">${staff.staffname}</td>
	    <td align="center">${staff.gender}</td>
	    <td align="center"><fmt:formatDate value="${staff.ondutydate}" pattern="yyyy-MM-dd" type="date"></fmt:formatDate> </td>
	    <td align="center">${staff.crmPost.crmDepartment.depname}</td>
	    <td align="center">${staff.crmPost.postname}</td>
	  	<td width="7%" align="center">
	  		
	  		<a href="${pageContext.request.contextPath}/staff/editStaff?staffId=${staff.staffid}"><img src="${pageContext.request.contextPath}/images/button/modify.gif" class="img" /></a>
	  	</td>
	  </tr>
	</c:forEach>
</table>



<table border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td align="right">
    	<span>第${pageUtil.currentPage}/${pageUtil.totalPage}页</span>
        <span>
        	<a href="${pageContext.request.contextPath}/staff/listStaff?page=1">[首页]</a>&nbsp;&nbsp;
            <a href="${pageContext.request.contextPath}/staff/listStaff?page=${pageUtil.currentPage==1?1:pageUtil.currentPage-1}">[上一页]</a>&nbsp;&nbsp;
            <a href="${pageContext.request.contextPath}/staff/listStaff?page=${pageUtil.currentPage==pageUtil.totalPage?pageUtil.totalPage:pageUtil.currentPage+1}">[下一页]</a>&nbsp;&nbsp;
            <a href="${pageContext.request.contextPath}/staff/listStaff?page=${pageUtil.totalPage}">[尾页]</a>
        </span>
    </td>
  </tr>
</table>

</body>
</html>
